package com.brk.socket.exception;

import com.brk.socket.common.ResultCodeEnum;

/**
 * @author brk
 * @date 2023/7/16 16:48
 * @Description:
 */
public class MyException extends RuntimeException{

    /**
     * 错误码
     */
    protected int errorCode;

    /**
     * 错误信息
     */
    protected String errorMsg;

    /**
     * 错误信息
     */
    protected Object errorData;

    /**
     * 错误信息
     */
    protected ResultCodeEnum codeEnum;

    /**
     * 定义无参构造方法
     */
    public MyException() {
        super();
    }

    /**
     * 定义有参构造方法
     *
     * @param codeEnum 错误信息
     */
    public MyException(ResultCodeEnum codeEnum) {
        this.codeEnum = codeEnum;
        this.errorCode = codeEnum.getCode();
        this.errorMsg = codeEnum.getMessage();
    }

    public MyException(int errorCode,String errorMsg){
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public int getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public Object getErrorData() {
        return errorData;
    }

    public void setErrorData(Object errorData) {
        this.errorData = errorData;
    }

    public ResultCodeEnum getCodeEnum() {
        return codeEnum;
    }

    public void setCodeEnum(ResultCodeEnum codeEnum) {
        this.codeEnum = codeEnum;
    }

}
